package com.sec.android.app.myfiles.feature;

import android.content.Context;

import com.sec.android.app.myfiles.feature.lockunlock.LockUnlockImp;
import com.sec.android.app.myfiles.info.AppFeatures;
import com.sec.android.app.myfiles.module.abstraction.FileRecord;
import com.sec.android.app.myfiles.operation.ProgressListener;

public class LockUnlockMgr {
    private static final boolean LOCK_UNLOCK_ENABLED = AppFeatures.SUPPORT_PINLOCK;

    private static LockUnlockMgr sInstance;
    private LockUnlockImp mLockUnlockImp;

    public static LockUnlockMgr getInstance() {
        if (sInstance == null) {
            sInstance = new LockUnlockMgr();
        }

        return sInstance;
    }

    private LockUnlockMgr() {
        if (LOCK_UNLOCK_ENABLED) {
            mLockUnlockImp = new LockUnlockImp();
        }
    }

    public static boolean isSupported() {
        return LOCK_UNLOCK_ENABLED;
    }

    public boolean isEncryptionFile(String path) {
        boolean bRet = false;
        if (mLockUnlockImp != null) {
            bRet = mLockUnlockImp.isEncryptionFile(path);
        }
        return bRet;
    }

    public void setDoNotShowConfirmDialog(Context context) {
        if (mLockUnlockImp != null) {
            mLockUnlockImp.setDoNotShowConfirmDialog(context);
        }
    }

    public boolean getDoNotShowConfirmDialog(Context context) {
        boolean bRet = false;

        if (mLockUnlockImp != null) {
            bRet = mLockUnlockImp.getDoNotShowConfirmDialog(context);
        }

        return bRet;
    }

    public boolean decFile(Context context, FileRecord record, ProgressListener listener) {
        boolean bRet = false;

        if (mLockUnlockImp != null) {
            bRet = mLockUnlockImp.decFile(context, record, listener);
        }

        return bRet;
    }

    public void cancel() {
        if (mLockUnlockImp != null) {
            mLockUnlockImp.cancel();
        }
    }

}
